import {
    Processor, WorkerHost,
    QueueEventsHost, QueueEventsListener, OnQueueEvent
} from '@nestjs/bullmq';
import { Job } from 'bullmq';

@Processor('audio')
export class AudioConsumer extends WorkerHost {
    async process(job: Job<any, any, string>, token?: string): Promise<any> {
        // TODO 消费逻辑
        console.log('开始消费:', job.data);
    }
}

// 队列事件监听器
@QueueEventsListener('audio')
export class AudioEventsListener extends QueueEventsHost {
    @OnQueueEvent('active')
    onActive(job: { jobId: string; prev?: string; }) {
        console.log(`Processing job ${job.jobId}...`,);
    }
}